export default {
  namespace: 'tabController',

  state: {
    closeOperate: false,
    oaPageInto: false,
    newUrl: [],
  },
  effects: {
    *closeTab({ payload }, { call, put }) {
      // 更新刷新标识
      yield put({
        type: 'globalM/save',
        payload: {
          listNeedRefresh: true,
        },
      });
      yield put({
        type: 'save',
        payload: {
          closeOperate: true,
          newUrl: payload.newUrl ? [payload.newUrl] : undefined, // 若关闭当前页面 不额外进行跳转新路由 传undefined
        },
      });
    },
  },
  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
    /* closeTab(state, { payload }) {
      return {
        ...state,
        closeOperate: true,
        ...payload,
      };
    }, */
  },
};
